package com.nuit.cxl;
import java.net.InetAddress;
import java.net.UnknownHostException;

public class Main {


    public static void main(String[] args) throws UnknownHostException {
            // 查询本机地址
//            InetAddress inetAddress1 = InetAddress.getByName("127.0.0.1");
//            System.out.println(inetAddress1);
//            InetAddress inetAddress2 = InetAddress.getByName("localhost");
//            System.out.println(inetAddress2);
            InetAddress inetAddress3 = InetAddress.getLocalHost();
            System.out.println(inetAddress3);

            // 查询网站IP地址

            // 常用方法
            InetAddress inetAddress = InetAddress.getByName("www.taobao.com");
            System.out.println(inetAddress.getAddress());   // 返回的是一个字节数组  无用
            System.out.println(inetAddress.getCanonicalHostName());    // 规范的名字
            System.out.println(inetAddress.getHostAddress());  // IP
//            System.out.println(inetAddress.getHostName()); // 域名，或者自己电脑的名字



        try {
            int b = 0;
            System.out.println("出错前");
            test(b);


            System.out.println("出错后");

        }catch (Exception e){
            System.out.println("第一个出错了");
        }


        int c = 1;
        try {
            test(c);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }


    }


    private static void test(int b) throws Exception{

            int a = 1/b;
            System.out.println(a);

    }


    private Main(){
    }
}